package moodish.client;

import javax.swing.table.DefaultTableModel;

import moodish.comm.ClientSideMessage;
import moodish.comm.component.ClientCommComponent;

public class ClientGuiThread extends Thread {

	private static ClientCommComponent clientComm;
	private static ClientSideMessage clientSideMessage;
	private static DefaultTableModel dtm;

	public ClientGuiThread(ClientCommComponent clientComm, DefaultTableModel dtm) {
		this.clientComm = clientComm;
		this.dtm = dtm;
		System.out.println("iniciado");
	}

	@Override
	public void run() {
		while (true) {
			if (clientComm.hasNextMessage()) {
				clientSideMessage = clientComm.getNextMessage();
				dtm.addRow(new Object[] {
						clientSideMessage.getSendersNickname(),
						clientSideMessage.getType() });
			}
		}
	}
}
